package org.sklse.lab.service;

import org.sklse.lab.bean.User;
import org.sklse.lab.dao.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    public UserRepository userRepository;

          //根据手机号查找用户
    public User findByPhonenumber(String phonenumber){
              return userRepository.findByphonenumber(phonenumber);
    }

    public void save(User entity) throws Exception {
           // 持久化
              userRepository.save(entity);

    }
    public Boolean UserSignup(User user) throws Exception{
        if(findByPhonenumber(user.getPhonenumber())==null){
              save(user);
              return true;
        }
        else{
            return false;
        }
    }



}
